
require 'nmap/program'
  Nmap::Program.scan do |nmap|
	nmap.xml = 'scan.xml'
	nmap.ping = true
	nmap.system_dns = true

    nmap.targets = '172.16.131.116'
  end
  
  require 'nmap/xml'

  Nmap::XML.new('scan.xml') do |xml|
  
	puts "\nAdresse ip    | Nom d'hote"
    xml.each_host do |host|
      @machine = Machine.find_by_nom_machine("#{host.hostnames}")
      if !@machine
  			@machine = Machine.new(:nom_machine => "#{host.hostnames}", :adresse_ip => "#{host.address}", :salle_id => 0)
  			@machine.save
  			puts "\nEnregistrement de : #{host.address}\t#{host.hostnames}"
			end
	 	end
	end
